package com.ctgu.tengyun.bean.convert;

import com.ctgu.tengyun.bean.response.ProductRepairListInfoResponse;
import com.ctgu.tengyun.domain.ProductRepairRecord;

import java.util.List;

/**
 * Created by liaoweizhi on 2019/8/12.
 */
public class ProductRepairRecordConvert {

    public static ProductRepairListInfoResponse toProductRepairListInfoResponse(Integer totalCount,
                                                                                Integer pageSize,
                                                                                List<ProductRepairRecord> repairRecordList) {
        ProductRepairListInfoResponse response = new ProductRepairListInfoResponse();

        response.setTotalCount(totalCount);
        response.setTotalPage((int) Math.ceil(totalCount / (double) pageSize));

        repairRecordList.forEach(item -> {
            item.setRepairFile(FileConvert.fillFileBeanUrlPath(item.getRepairFile()));
        });
        response.setRepairRecordList(repairRecordList);
        return response;
    }

    public static ProductRepairRecord fillRepairRecord(ProductRepairRecord fileTemplate) {
        fileTemplate.setRepairFile(FileConvert.fillFileBeanUrlPath(fileTemplate.getRepairFile()));
        return fileTemplate;
    }

}
